<?php

namespace app\api\model;

use think\Model;
use traits\model\SoftDelete;

class Teachers extends Model
{
    use SoftDelete;
    protected $deleteTime = 'deletetime';
    protected $hidden = ['deletetime', 'createtime', 'updatetime'];

    public static function getByPhone($phone)
    {
        return self::where('phone', $phone)->find();
    }

    public function classes()
    {
        return $this->belongsToMany(Classes::class, 'teacher_classes', 'class_id', 'teacher_id');
    }

    public static function getByAccount($account)
    {
        return self::with(['classes'])->where('account', $account)->find();
    }


}
